package board;

import java.awt.*;

import sgf.SGFParseException;
import sgf.SGFUtils;
import ui.GobanPanel;

/**
 * Represents a mark on the Board.
 * @author TKington
 *
 */
public class SimpleMark extends NodeMark {
	/** The x,y location of the mark on the board. */
    protected Point pt;
    
    /**
     * Creates a new SimpleMark object.
     * @param t the type
     * @param p the x,y location on the Board
     */
    public SimpleMark(int t, Point p) {
        type = t;
        pt = p;
    }
   
    /**
     * Returns the x,y location of the mark.
     * @return the Point
     */
    public Point getPoint() { return pt; }
    
    @Override
	public Object clone() {
    	return new SimpleMark(type, new Point(pt));
    }
    
    @Override
	public boolean equals(Object o) {
        if(!(o instanceof SimpleMark))
            return false;
        
        SimpleMark m = (SimpleMark)o;
        if(!pt.equals(m.pt))
            return false;
        if(type != m.type)
            return false;
        return true;
    }
    
    @Override
	public void validatePoints(int size) throws SGFParseException {
        SGFUtils.checkPoint(pt, size);
    }
    
    @Override
	public void invalidatePanel(GobanPanel panel) {
        panel.repaint(pt.x, pt.y);
    }
    
    @Override
	public Rectangle getBounds() {
        return new Rectangle(pt);
    }
}
